(ns cljsso.config
  (:require [clojure.edn :as e]
            [clojure.java.io :as io]
            [clojure.pprint :refer [pprint]])
  (:import  [java.util UUID]))

(defonce cfg
  "config-cljsso.edn")


(defn read-props
  "Read properties from config, if not found create with default vals"
  []
  (if (.exists (io/file cfg))
    (e/read-string (slurp cfg))
    (throw (RuntimeException. "config-cljsso.edn file not found!"))))


(def props
  (read-props))


(def mdata-tables
  #{"ecg" "nibp" "spo2" "temp" "hrv"})

(defonce one-day-in-millis
  (* 3600 1000 24))

(defonce server-id
  (or (:servcode props) (UUID/randomUUID)))

(defonce version-id
  (or (:version props) server-id))


(defonce dev?
  (:dev? props))

(def return-codes
  {:cljsso-success   0
   :cljsso-exception 1
   :cljsso-end       2
   :cljsso-fail      3})
